<?php
require_once 'extension/ckfinder/ckfinder.php' ;
class Henry_Editor_Ckfinder {
	private $ckfinderOb;
	public function __construct()
	{
		$ckfinderOb = new CKFinder() ;
		$ckfinderOb->BasePath = BASE_URL.'/extension/ckfinder/' ;	
		$ckfinderOb->SelectFunction = 'ShowFileInfo' ;
		$this->ckfinderOb = $ckfinderOb;
	}
	public function create()
	{
		$this->ckfinderOb->Create();
	}
	public function popup()
	{
		$path = BASE_URL.'/extension/ckfinder/';
		$str = "<script type=\"text/javascript\">
			function BrowseServer(startupPath,field,rel)
			{
				var finder = new CKFinder();
				finder.basePath = '$path';	
				finder.startupPath = startupPath;
				finder.selectActionFunction = function(url) {SetFileField(field,rel,url)}
				finder.popup();
			}
			function SetFileField(field,rel,fileUrl )
			{
				document.getElementById(field).value = fileUrl;
				$('#'+rel).attr('src',fileUrl.replace('images','_thumbs/Images'));
				$('#'+rel).css('display','block');
			}
			</script>
		";
		return $str;
	}
}

?>